import React, { Component } from 'react';
import '../../styles/ProductPage/MyList.css';
import { withRouter } from 'react-router-dom'
import { good_list } from "../../api/index";
// import pic1 from "../../images/tab/分类页-tab切换 (1).jpg";

class MyList extends Component {
    constructor(props) {
        super(props)
        this.state = {
            item3id: "",
            list: [
                // { name: 'Fliorge费罗嘉柔', img: pic1, money: 304, gomoney: 195 },
            ],
            id: {}
        }

    }
    componentDidMount() {
        good_list({token:localStorage.getItem('token'),id:this.props.match.params.id}).then((res) => {
            this.setState({
                list: res.data.list
            })
        })
    }

    toShopcart(id) {
        this.props.history.push("/detail/" + id)
        //   this.props.history.push('/index/ProductPage/'+id);//跳动态路由 
    }
    render() {
        return (
            <div className='main'>
                {
                    this.state.list.map((item, index) => {
                        return (
                            <div className='libox' key={index} onClick={() => { this.toShopcart(item.id) }}>
                                <img src={item.pic} alt="" />
                                <p>{item.name}</p>
                                <p>原价:￥{item.money}</p>

                            </div>
                        )
                    })
                }
            </div>
        );
    }
}

export default withRouter(MyList);